#ifndef __THREAD_MANAGER_H__
#define __THREAD_MANAGER_H__
#include <rtdevice.h>
#define MSG_MAX_HOST           10
#define MSG_MAX_COMM           11

#define CAN_PROTOCOL_DATA   0x01

#define HOST_THREAD_CIRCLE      100

enum CAN_Data
{
    CAN_Data_SV = 0x01,
    CAN_Data_PV,
    CAN_Data_TEC_Power,
    CAN_Data_Work_Mode,
};

enum Arg_ID
{
    ARG_ID_SV = 0,
    ARG_ID_TempAlarmLow,
    ARG_ID_TempAlarmHigh,
    ARG_ID_AT,
    ARG_ID_TECCtrlMode,
    ARG_ID_TECPower,
    ARG_ID_WorkMode,
    ARG_ID_PIDKp,
    ARG_ID_PIDKi,
    ARG_ID_PIDKd,
    ARG_ID_Reserved1,
    ARG_ID_Reserved2,
    ARG_ID_Reserved3,
    ARG_ID_SVOffset,
    ARG_ID_PVOffset,
    ARG_ID_TECOutputDir,
    ARG_ID_TempSensorType,
    ARG_ID_TempUnit,
    ARG_ID_DecimalPointNbr,
    ARG_ID_DisplayRangeLow,
    ARG_ID_DisplayRangeHigh,
    ARG_ID_FilterDegree,
    ARG_ID_MBSlaverAddr,
    ARG_ID_MBBaudrateID,
    ARG_ID_ProgCurrentStep,
    ARG_ID_ProgTimeUnitAdjust,
    ARG_ID_ProgTimeUnitHold,
    ARG_ID_ProgStart,
    ARG_ID_ProgTempAcceptance,
    ARG_ID_ProgStep1AdjustTime,
    ARG_ID_ProgStep1Sv,
    ARG_ID_ProgStep1HoldTime,
    ARG_ID_ProgStep1Mode,
    ARG_ID_ProgStep1NextStepNbr,
    ARG_ID_ProgStep1LoopCnt,
    ARG_ID_ProgStep2AdjustTime,
    ARG_ID_ProgStep2Sv,
    ARG_ID_ProgStep2HoldTime,
    ARG_ID_ProgStep2Mode,
    ARG_ID_ProgStep2NextStepNbr,
    ARG_ID_ProgStep2LoopCnt,
    ARG_ID_ProgStep3AdjustTime,
    ARG_ID_ProgStep3Sv,
    ARG_ID_ProgStep3HoldTime,
    ARG_ID_ProgStep3Mode,
    ARG_ID_ProgStep3NextStepNbr,
    ARG_ID_ProgStep3LoopCnt,
    ARG_ID_ProgStep4AdjustTime,
    ARG_ID_ProgStep4Sv,
    ARG_ID_ProgStep4HoldTime,
    ARG_ID_ProgStep4Mode,
    ARG_ID_ProgStep4NextStepNbr,
    ARG_ID_ProgStep4LoopCnt,
    ARG_ID_ProgStep5AdjustTime,
    ARG_ID_ProgStep5Sv,
    ARG_ID_ProgStep5HoldTime,
    ARG_ID_ProgStep5Mode,
    ARG_ID_ProgStep5NextStepNbr,
    ARG_ID_ProgStep5LoopCnt,
    ARG_ID_ProgStep6AdjustTime,
    ARG_ID_ProgStep6Sv,
    ARG_ID_ProgStep6HoldTime,
    ARG_ID_ProgStep6Mode,
    ARG_ID_ProgStep6NextStepNbr,
    ARG_ID_ProgStep6LoopCnt,
    ARG_ID_ProgStep7AdjustTime,
    ARG_ID_ProgStep7Sv,
    ARG_ID_ProgStep7HoldTime,
    ARG_ID_ProgStep7Mode,
    ARG_ID_ProgStep7NextStepNbr,
    ARG_ID_ProgStep7LoopCnt,
    ARG_ID_ProgStep8AdjustTime,
    ARG_ID_ProgStep8Sv,
    ARG_ID_ProgStep8HoldTime,
    ARG_ID_ProgStep8Mode,
    ARG_ID_ProgStep8NextStepNbr,
    ARG_ID_ProgStep8LoopCnt,
    ARG_ID_PowerOnAutoRun,
    ARG_ID_SteadyAlarmRange,
    ARG_ID_TECMaxPower,
    ARG_ID_MBCrcEnable,
    ARG_ID_ErrorCode,
    ARG_ID_Reserved57,
    ARG_ID_Reserved58,
    ARG_ID_Reserved59,
    ARG_ID_PIDMode,
    ARG_ID_TempCalibReal0,
    ARG_ID_TempCalibReal1,
    ARG_ID_TempCalibReal2,
    ARG_ID_TempCalibReal3,
    ARG_ID_TempCalibReal4,
    ARG_ID_TempCalibReal5,
    ARG_ID_TempCalibReal6,
    ARG_ID_TempCalibReal7,
    ARG_ID_TempCalibReal8,
    ARG_ID_TempCalibReal9,
    ARG_ID_TempCalibSet0,
    ARG_ID_TempCalibSet1,
    ARG_ID_TempCalibSet2,
    ARG_ID_TempCalibSet3,
    ARG_ID_TempCalibSet4,
    ARG_ID_TempCalibSet5,
    ARG_ID_TempCalibSet6,
    ARG_ID_TempCalibSet7,
    ARG_ID_TempCalibSet8,
    ARG_ID_TempCalibSet9,
    ARG_ID_TempCalibPointNbr,
    ARG_ID_Factory,
    ARG_ID_PV, 
};

struct Msg_InterThread
{
    rt_uint8_t arg_id;
    rt_uint16_t arg_value;
};

extern struct rt_messagequeue *mq_host;
extern struct rt_messagequeue *mq_comm;
extern rt_int32_t sensor_temp[16];
extern rt_uint32_t slaver_online;
int comm_thread_init(void);
int host_thread_init(void);
int thread_can_init(void);
// void can_send_cmd(rt_uint32_t can_id, rt_uint8_t cmd_id);
void can_send_data(rt_uint32_t can_id, rt_uint8_t data_id, rt_uint8_t *data, rt_uint8_t len);
#endif
